import { Transform } from 'class-transformer';
import { IsNotEmpty, IsNumber } from 'class-validator';

/*
 * @Author: jingfuu@163.com
 * @Date: 2024-11-25 10:49:32
 * @LastEditTime: 2024-11-25 11:00:10
 * @Description: file content
 */
export class AuthRoleDto {
  @IsNumber({}, { message: '用户ID必须为数字' })
  @Transform(({ value }) => parseInt(value, 10))
  userId: number;

  @IsNotEmpty({ message: '角色ID不能为空' })
  @Transform(({ value }) =>
    value.split(',').map((item) => parseInt(item.trim(), 10)),
  )
  roleIds: number[];
}
